<?php
class IdentifyModel
{
	private $db;
	
	public function __construct()
	{
		$this -> db = new dataBase;
		//exit;
	}
	public function getAllusers()
	{
		$sql =	"SELECT * FROM users WHERE flag_active=true AND flag_block=false AND flag_trash=false";
		$aResult= $this -> db -> Query($sql,array());
		
		return $aResult;
	}
	public function getOneUser($login)
	{
		$aQuery = "SELECT * FROM users WHERE user_login=?";
		$aResult = $this -> db -> ExecuteQuery($aQuery,array($login));
		
		return $aResult;
	}
	
	public function saveUser($login,$pass,$email,$activationKey)
	{
		$aQuery = "INSERT INTO users (user_login,user_password,user_email,activation_key) VALUES (?,?,?,?)";
		$aResult = $this -> db -> ModifyQuery($aQuery, array($login,md5($pass),$email,$activationKey));
		
		return($aResult);
	}
	
	public function getActivationUser($login, $activ)
	{
		$aQuery = "SELECT * FROM users WHERE md5(user_login)=? AND activation_key=?";
		$aResult = $this -> db -> ExecuteQuery($aQuery,array($login,$activ));
		
		return($aResult);
	}
	
	public function activeUser($login)
	{
		$aQuery = "UPDATE users SET user_flag_active=true WHERE md5(user_login)=?";
		$aResult = $this -> db -> ExecuteQuery($aQuery,array($login));
		
		return($aResult);
	}
}
?>